home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PsL Monthly 1993 December
/
PSL Monthly Shareware CD-ROM (December 1993).iso
/
prgmming
/
dos
/
c
/
uw_1.exe
/
UW_HELP3.HLP
< prev
next >
Wrap
Text File
|
1992-11-03
|
23KB
|
666 lines
`co(4,7);──────────────────────── /// The Keyboard/Mouse ──────────────────────────────`co();
┌──────────────────────────────────────────────────────────────────────────┐
│ `keyword(init_mouse,/// init_mouse); `keyword(end_mouse ,/// end_mouse); `keyword(m_reset ,/// m_reset); │
│ `keyword(set_idle_func,/// set_idle_func); `keyword(set_key_func,/// set_key_func); `keyword(get_key ,/// get_key); │
│ `keyword(wait_event,/// wait_event); `keyword(event_pending,/// event_pending); `keyword(m_pos ,/// m_pos); │
│ `keyword(wait_ticks,/// wait_ticks); `keyword(check_key ,/// check_key); `keyword(m_released ,/// m_released); │
│ `keyword(m_hide,/// m_hide); `keyword(m_show ,/// m_show); `keyword(m_motion ,/// m_motion); │
│ `keyword(m_moveto,/// m_moveto); `keyword(m_pressed ,/// m_pressed); `keyword(m_ratio ,/// m_ratio); │
│ `keyword(m_colrange,/// m_colrange); `keyword(m_rowrange,/// m_rowrange); │
│ `keyword(m_lpen_on,/// m_lpen_on); `keyword(m_lpen_off,/// m_lpen_off); │
└──────────────────────────────────────────────────────────────────────────┘
The UltraWin library interfaces to the user through either the keyboard,
mouse, or both. The keyboard routines support all possible key presses
which include left and right Shift, Alt, and Ctrl key combinations. The
mouse routines allow complete control of a two or three button mouse, and
is Microsoft driver compatible. The event routines handle detecting both
mouse and keyboard presses for you, so making your programs support a
mouse is a snap! In addition, UltraWin allows you to define your own
background function, which is called any place in the library that waits
for user input. This allows you to write your own processing routines to
be performed in the background, then call one function to notify the
library of your routine, then just forget all about it! Refer to the
set_idle_func and wait_event functions for details.
`co(10,1);/// init_mouse`co(); `keyword(source,[UW_EVENT.C]~init_mouse);
Call this function just after init_video or force_video if you wish to
use the mouse in your program. If the mouse is connected and a driver is
installed, then the global variable Mouse_exists is set to TRUE (1). In
addition the mouse cursor column and row ranges are set to cover the
entire text screen. After calling this function you may show the mouse on
the screen using the function m_show.
Prototype:
void init_mouse(void);
Parameters:
None.
Usage:
init_mouse();
`co(10,1);/// end_mouse`co(); `keyword(source,[UW_EVENT.C]~end_mouse);
If the mouse was found to be present in init_mouse, this function turns
the mouse back off. This keeps the mouse from being active at the DOS
prompt. Call this prior to exiting your program if your program called
init_mouse or the lower level m_reset function.
Prototype:
void end_mouse(void);
Parameters:
None.
Usage:
end_mouse();
`co(10,1);/// m_reset`co(); `keyword(source,[UW_EVENT.C]~m_reset);
This is the lower level function called by both init_mouse and
end_mouse. It is used both to determine if the mouse exists, and also to
reset the mouse prior to program exit.
Prototype:
void m_reset(M_RESET *m)
Parameters:
`co(11,1); M_RESET *m`co();
A variable of type M_RESET. Refer to the structures/globals topic for
information on the members of this structure.
Usage:
M_RESET m;
...
m_reset(&m);
`co(10,1);/// set_idle_func`co(); `keyword(source,[UW_EVENT.C]~set_idle_func);
Allows you to define your own background process. Simply write your own
C function, keeping in mind that to remain responsive to the keyboard you
should keep your code tight and fast. Then call set_idle_func with the
pointer to your function.
Prototype:
void set_idle_func( int (*func_ptr)(void) );
Parameters:
`co(11,1); int (*func_ptr)(void)`co();
A pointer to the function you wish to install as the idle function.
Usage:
process()
{
...
}
...
set_idle_func( process );
`co(10,1);/// wait_event`co(); `keyword(source,[UW_EVENT.C]~wait_event);
Waits until either a key is pressed, or a mouse button is clicked. The
global variable Event will contain the information about the event. If it
is a keyboard event, the key or combination of keys pressed is saved. If
a mouse event, then the button that was pressed, how many times it was
pressed, and the x and y coordinate at which the press occurred is saved.
While UltraWin waits for user input, it is free to perform background
processing. If a user defined function has been installed with
set_idle_func, that function will be called during idle time.
Prototype:
void wait_event(void);
Parameters:
None.
Usage:
wait_event();
`co(10,1);/// event_pending`co(); `keyword(source,[UW_EVENT.C]~event_pending);
Checks for an event, and returns TRUE (1) if an event has occurred or
FALSE (0) if no event has occurred. If an event has occurred, then the
information about the event, which includes the event type (keyboard or
mouse), the key and modifier, or the mouse location and button status is
returned in the global Event variable. Refer to `keyword(Structures/Globals,[uw_help1.hlp]/// Structures/Globals); for
information about the EVENT structure and member names for extracting
this information.
Prototype:
int event_pending(void);
Parameters:
None.
Usage:
int status;
...
status = event_pending();
`co(10,1);/// wait_ticks`co(); `keyword(source,[UW_EVENT.C]~wait_event);
Waits for a given number of system ticks. There are 18.2 system ticks
per second. If you have defined a background process with the
set_idle_func function, it will call your process function while it waits
for the given ticks to pass. UltraWin now has enhanced timer support.
See `keyword(Timer/Sound Support,[uw_help6.hlp]/// Timer/Sound Support); for further details.
Prototype:
void wait_ticks( clock_t ticks );
Parameters:
`co(11,1); int ticks`co();
The number of system ticks to wait. Be sure to pass this as a long or
cast your number to a clock_t.
Usage:
wait_ticks( 9L );
wait_ticks( (clock_t) 37 );
`co(10,1);/// check_key`co(); `keyword(source,[UW_EVENT.C]~check_key);
Checks to see if a key has been pressed, and returns the key without
pulling it out of the keyboard buffer. The key value is returned (see
UW_KEYS.H for key defines). If no key has been pressed, then check_key
will return FALSE (0).
You can "capture" any key by installing a function that is called by
check_key. This is set by calling `keyword(set_key_func,/// set_key_func);. Check key will
pass this function the key and modifier. When the called function
returns, if 1 is returned, check_key acts as though no key was ever
hit, if a 0 is returned, the key is then passed through. This is a
very useful, low-level way to supply "hot-keys" anywhere in your
program, even while entering data!
Prototype:
int check_key(void);
Parameters:
None.
Usage:
int key;
...
key = check_key();
`co(10,1);/// set_key_func`co(); `keyword(source,[UW_EVENT.C]~set_key_func);
Allows you to define your own "hotkey" function. Simply write your own
"C" function, keeping in mind that to remain responsive to the keyboard you
should keep your code tight and fast. Then call set_key_func with the
pointer to your function. Your function is passed the key and key
modifier. See `keyword(check_key,/// check_key); for more details.
Prototype:
void set_key_func( int (*func_ptr)(int, int) );
Parameters:
`co(11,1); int (*func_ptr)(int, int)`co();
A pointer to the function you wish to install as the key function.
Usage:
process(int key